#{extends 'home.html' /} 
#{set title:'User Invitations'/}

<h1 class="viewTitle">Requests :-</h1>
<div class="viewContent">

#{if size == false}
<h2> You do not have any Requests</h2>
#{/if}
#{elseif ifUserNull==1}
<h2> You are not authorized to view this page</h2>
#{/elseif}
#{else}
    
		#{table allRequests, as: 'request'}
			#{column 'Request'}${request.description}
			#{/column}
			#{column 'Description'}
			#{if request.description == 'OrganizerResign'}
			<a href = "@{Users.viewUserProfile(request.sendingUser.userName)}" class = "standardLink">${request.sendingUser.name}</a>
			has suggested you to 
            take over his responsibilities as the organizer of 
            <a href = "@{Browse.viewEntity(request.entity.id)}" class="standardLink">
            ${request.entity.name}
            </a>
            entity instead of him/her.
			#{/if}
			#{elseif request.description == 'OrganizationLeadResign'}
            <a href = "@{Users.viewUserProfile(request.sendingUser.userName)}" class = "standardLink">${request.sendingUser.name}</a>
            has suggested you to 
            take over his responsibilities 
            as the organization lead of 
            <a href = "@{Browse.viewOrganization(request.organization.id)}" class = "standardLink">
            ${request.organization.name}</a>
            organization instead of him/her.
			#{/elseif}
			#{elseif request.entity==null}
			<a href = "@{Users.viewUserProfile(request.sendingUser.userName)}" class = "standardLink">${request.sendingUser.name}</a>
			 has invited you to   <a href = "@{Browse.viewOrganization(request.organization.id)}">
			${request.organization.name}</a>
			#{/elseif}
			#{else}
			<a href = "@{Users.viewUserProfile(request.sendingUser.userName)}" class = "standardLink">${request.sendingUser.name}</a>
			has invited you to   <a href = "@{Browse.viewEntity(request.entity.id)}">
			${request.entity.name}</a>
			#{/else}
			#{/column}			
			#{column 'Accept '}
			#{if request.description == 'OrganizationLeadResign'}
			<a href = "@{RequestController.acceptOrganizationLeadResignRequest(request.id)}">
			<img src = "@{'/public/images/YES.png'}">
			</img>
			</a>
			#{/if}
			#{elseif request.description == 'OrganizerResign' }
			<a href = "@{RequestController.acceptOrganizerResignRequest(request.id)}">
			<img src = "@{'/public/images/YES.png'}">
			</img>
			</a>
			#{/elseif}
			#{elseif entity==null}
			<a href = "@{RequestController.acceptRequest(request.organization.id,-1,request.id)}">
			<img src = "@{'/public/images/YES.png'}">
			</img>
			</a>
			#{/elseif}
			#{else}
			<a href = "@{RequestController.acceptRequest(-1,request.entity.id,request.id)}">
			<img src = "@{'/public/images/YES.png'}">
			</img>
			</a>
			#{/else}
			#{/column}
			#{column 'Ignore '}
			#{if request.description == 'OrganizationLeadResign'}
			<a href = "@{RequestController.ignoreOrganizationLeadResignRequest(request.id)}">
			<img src = "@{'/public/images/NO.png'}">
			</img>
			</a>
			#{/if}
			#{elseif request.description == 'OrganizerResign' }
			<a href = "@{RequestController.ignoreOrganizerResignRequest(request.id)}">
			<img src = "@{'/public/images/NO.png'}">
			</img>
			</a>
			#{/elseif}
			#{elseif entity==null}
			<a href = "@{RequestController.IgnoreRequest(request.organization.id,-1,request.id)}">
			<img src = "@{'/public/images/NO.png'}">
			</img>
			</a>
			#{/elseif}
			#{else}
			<a href = "@{RequestController.IgnoreRequest(-1,request.entity.id,request.id)}">
			<img src = "@{'/public/images/NO.png'}">
			</img>
			</a>
			#{/else}
			#{/column}
		#{/table}
	
	#{/else}
	</div>
